<?php
/*
 * @Author: 哲学家乔布斯 <wuyangii@qq.com>
 * @Date: 2022-10-25 20:19:21
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-10-25 20:22:43
 * @Descripttion: 
 */


namespace app\common\model;

use think\Model;

class AgentOrderGoods extends Base
{
    protected $insert = ['addtime'];

    //---------------自动完成----------------------
    protected function setAddtimeAttr()
    {
        return time();
    }
   
    /**
     * 获取图片数组
     *
     * @param [type] $value
     * @param [type] $data
     * @return void
     */
    public function getCoverImageTextAttr($value, $data)
    {
        return cdnurl($data['cover_image'],true);
    }
 
    public function getSkuAttr($value,$data){
        return (new \app\common\model\GoodsSku())->field(['id','sku_title','money'])->where(['goods_id' => $data['id']])->select();
    }
    public function getBusUserNameAttr($value,$data){
        return (new \app\common\model\Bus())->where(['id' => $data['bus_id']])->value('user_name');
    }
    public function getAgentUserNameAttr($value,$data){
        return (new \app\common\model\Agent())->where(['id' => $data['agent_id']])->value('usename');
    }

    public function getGoodsCateTitleAttr($value,$data){
        return (new \app\common\model\Classify())->where(['id' => $data['goods_cate_id']])->value('name');
    }
    public function getGoodsBrandTitleAttr($value,$data){
        return (new \app\common\model\GoodsBrand())->where(['id' => $data['goods_brand_id']])->value('title');
    }
    public function getCarTitleAttr($value,$data){
        return (new \app\common\model\GoodsCar())->where(['id' => $data['car_id']])->value('title');
    }
    public function getAddtimeTextAttr($value,$data){
        return date("Y-m-d H:i:s",$data['addtime']);
    }
    public function getStateTextAttr($value,$data){
        $arr = [0=>'已支付',1=>'已发货',2=>'拒绝'];
        return $arr[$data['state']];
    }
}
